package bairui.international.console.web.controller.service.service;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import com.lianjing.sh.model.uml.model.status.State_UpDown;
import com.lianjing.sh.project.config.web.Project_Config_Web_PageTemplate;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.module.context.ModuleContext;
import com.lianjing.sh.spring.web.controller.enhance.navigations.context.NavigationContext;

import bairui.international.console.web.controller.service.C_Service_Index_Left;
import bairui.international.model.domain.jpa.TB_Service;
import bairui.international.service.Service_Service;

/**
 *
 * 编辑
 *
 * @generated
 * 
 * @see STest_C_ServiceService_Edit_EditAccess 测试
 *
 */
@Controller
public class C_ServiceService_Edit_EditAccess
 extends SC_ServiceService_Edit_EditAccess 
{
	
	@Autowired private Service_Service service_Service;
	
	/**
	 * 访问编辑页面
	 */
	@Action(EditAccess.class)
	@GetMapping(EditAccess.RequestMappingValue)
	public ModelAndView editAccess(
		ModelMap map, HttpServletRequest request,
		NavigationContext navigationContext, ModuleContext moduleContext
	) throws Exception {
		/* 侧边栏 */
		C_Service_Index_Left.importPage(map);
		TB_Service service = service_Service.findFirst();
		if(null == service){
			service = service_Service.save(new TB_Service(new TB_Service.MustProperties() {
				@Override public State_UpDown getState() {
					return State_UpDown.t_create().to();
				}
			}));
		}
		long id = service.getId();
		State_UpDown state_UpDown = service.getState();
		/* 模块 */
		moduleContext
			.addModule(module_Edit.module(
					service,
					new Module_Edit_Head_OutputModel(service),
					new C_ServiceService_Edit_Edit.Edit.Operate(){
					}, 
					new C_ServiceService_Publish_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public com.lianjing.sh.model.uml.model.status.State_UpDown getState_UpDown() { return state_UpDown; }
					}, 
					new C_ServiceService_Up_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public com.lianjing.sh.model.uml.model.status.State_UpDown getState_UpDown() { return state_UpDown; }
					}, 
					new C_ServiceService_Down_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public com.lianjing.sh.model.uml.model.status.State_UpDown getState_UpDown() { return state_UpDown; }
					}
				));
		//
		return Project_Config_Web_PageTemplate.Admin_Common(request);
	}
	

}
